﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestConsole
{
	class Program
	{
		static void Main(string[] args)
		{
			// Show all students
			
			SchoolDBEntities a = new SchoolDBEntities();
			//List<Course> courseList = a.Course.Where(b => b.CourseId == 10).ToList();
			//foreach( Course cs in courseList )
			//{
				
			//    Console.WriteLine( cs.CourseId.ToString() + "	" + cs.CourseName );
			//}
			Course cs = a.Course.SingleOrDefault(p => p.CourseId == 10);
			Student stu = a.Student.SingleOrDefault(p => p.StudentID == 1);


			if (null != stu)
			{
				Console.WriteLine(stu.StudentID.ToString() + "	" + stu.StudentName);
				stu.StudentName = "Adam Lan";
				a.SaveChanges();
			}

			stu = a.Student.SingleOrDefault(p => p.StudentID == 1);
			Console.WriteLine(stu.StudentID.ToString() + "	" + stu.StudentName);
			//using SchoolDBEntities a = new SchoolDBEntities()
			//{
			//     IList<Course> courseList = (from cs in Course
			//               where cs.CourseName == "Course1"
			//               select cs).ToList<Course>();
			//    Course mathCourse = courseList.FirstOrDefault<Course>();

			//    string courseName = mathCourse.CourseName;
			//}

			Console.ReadLine();
        }
	}
}
